using ASP;
using HoWave.Alipay;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
public class paygift_notify_url : Member, IRequiresSessionState
{
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		SortedDictionary<string, string> requestPost = this.GetRequestPost();
		if (requestPost.Count > 0)
		{
			Notify notify = new Notify();
			bool flag = notify.Verify(requestPost, base.Request.Form["notify_id"], base.Request.Form["sign"]);
			if (flag)
			{
				string text = base.Request.Form["trade_no"];
				string text2 = base.Request.Form["out_trade_no"];
				string text3 = base.Request.Form["total_fee"];
				string text4 = base.Request.Form["subject"];
				string text5 = base.Request.Form["body"];
				string text6 = base.Request.Form["buyer_email"];
				string text7 = base.Request.Form["trade_status"];
				OrderAction orderAction = new OrderAction(this.conn);
				if (base.Request.Form["trade_status"] == "TRADE_FINISHED")
				{
					base.Response.Write("success");
					PayOnline payOnline = new PayOnline();
					payOnline.SetPayOK(text2);
					int num = (int)this.conn.GetScalar("Select UserID From HL_PayOnline WHERE PayNum= '" + text2 + "'", new IDbDataParameter[0]);
					this.conn.Execute(string.Concat(new object[]
					{
						"UPDATE [HL_User] SET [Balance] = [Balance]+",
						text3,
						" WHERE [UserID] = ",
						num
					}));
				}
				else
				{
					if (base.Request.Form["trade_status"] == "TRADE_SUCCESS")
					{
						base.Response.Write("success");
						PayOnline payOnline = new PayOnline();
						payOnline.SetPayOK(text2);
						int num = (int)this.conn.GetScalar("Select UserID From HL_PayOnline WHERE PayNum= '" + text2 + "'", new IDbDataParameter[0]);
						this.conn.Execute(string.Concat(new object[]
						{
							"UPDATE [HL_User] SET [Balance] = [Balance]+",
							text3,
							" WHERE [UserID] = ",
							num
						}));
					}
				}
				base.Response.Write("success");
			}
			else
			{
				base.Response.Write("fail");
			}
		}
		else
		{
			base.Response.Write("无通知参数");
		}
	}
	public SortedDictionary<string, string> GetRequestPost()
	{
		SortedDictionary<string, string> sortedDictionary = new SortedDictionary<string, string>();
		NameValueCollection form = base.Request.Form;
		string[] allKeys = form.AllKeys;
		for (int i = 0; i < allKeys.Length; i++)
		{
			sortedDictionary.Add(allKeys[i], base.Request.Form[allKeys[i]]);
		}
		return sortedDictionary;
	}
}
